package com.unitechs.trap.excel.webapi.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.unitechs.trap.common.restful.JsonResult;
import com.unitechs.trap.excel.service.ILogTestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "日志整理")
@RequestMapping("/log")
public class LogController {
    @Autowired
    ILogTestService logTestService;

    @GetMapping("/file/toexcel")
    @ApiOperation("1、日志文件整合到Excel中")
    @ApiImplicitParam(value = "文件路径",name = "url",example = "G:\\trap规则整理\\UDP数据\\1、Log文件\\未执行的日志")
    public JsonResult getTrapOidByMessage(String url){
        logTestService.logFileToExcel(url);
        return JsonResult.ok();
    }

    @GetMapping("/excel/tojosn")
    @ApiOperation("2、将Excel中的日志转换成Json格式")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "文件路径",name = "url",example = "G:\\trap规则整理\\UDP数据\\3、Excel生成Json"),
            @ApiImplicitParam(value = "设备IP",name = "devicesIp",example = "210.78.3.112")
    })
    public JsonResult getChangeLogToJson(String url,String devicesIp){
        logTestService.changeLogToJson(url,devicesIp);
        return JsonResult.ok();
    }
    @GetMapping("/test/from/interface")
    @ApiOperation("3、调用接口测试")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "文件路径",name = "fileUrl",example = "G:\\trap规则整理\\UDP数据\\3、接口测试"),
            @ApiImplicitParam(value = "接口路径",name = "interfaceUrl",example = "http://192.168.212.20:7007/api/ala/traprule/analysistest"),
            @ApiImplicitParam(value = "token值",name = "token",example = "web_eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxMDY3OTU1IiwibmV0VXNlcmlkIjoiemhvdXl6IiwidXNlck5hbWUiOiLlkajnjonmm4wiLCJleHAiOjE2Nzk3OTM5ODl9.Z1_KjqmCkPJ7ut3VWNq2HVwLE0MpL4Kp2_y6h9bpoMYJM0LSelTcSy0mkGMDGUkr5yP-z8tKnvflG5U3wJt3WA")

    })
    public JsonResult sendRequestToInterFace(String fileUrl,String interfaceUrl, String token){
        logTestService.sendRequestToInterFace(fileUrl,interfaceUrl,token);
        return JsonResult.ok();
    }
}
